package ws.jonas.sybosc.gui;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class StatusBarPanel extends JPanel {
	private final JLabel textLabel;
	private final JPanel statusPane;

	public StatusBarPanel() {
		setLayout(new BorderLayout());
		textLabel = new JLabel();
		statusPane = new JPanel();
		add(textLabel, BorderLayout.CENTER);
		add(statusPane, BorderLayout.LINE_END);
		onDisconnect();
	}

	public void onConnect() {
		statusPane.removeAll();
		statusPane.add(new JLabel("Connected"));
		statusPane.add(new JLabel(GuiUtil.Images.ONLINE));
		statusPane.validate();
		statusPane.repaint();
	}

	public void onDisconnect() {
		statusPane.removeAll();
		statusPane.add(new JLabel("Disconnected"));
		statusPane.add(new JLabel(GuiUtil.Images.OFFLINE));
		statusPane.validate();
		statusPane.repaint();
	}

	public void updateStatusText(String text) {
		textLabel.setText("  " + text);
		textLabel.validate();
		textLabel.repaint();
	}
}
